

function createAvatarWindow(mid){
    /*
       $("#cropbox_div_container").AeroWindow({
        WindowTitle:          "Chỉnh sửa ảnh đại diện",
        WindowPositionTop:    'center',
        WindowPositionLeft:   'center',
        WindowMaximize:       false,
        WindowMinimize:       false,
        WindowWidth:          710,
        WindowHeight:         450,
        WindowAnimation:      'easeOutCubic'
    });
    */
   Lightbox.show(domain+"/thanh-vien?mid="+mid+"&action=crop_image",809,500,"Chỉnh sửa ảnh đại diện","iframe");
    //$('#cropbox_div_container').lightbox();
    /*
    $('#cropbox_div_container').dialog({
        modal: true,
        width:725,
        title:"Chỉnh sửa ảnh đại diện",
        open: function(event, ui) {
            if($('#reloadAvatarCrop').val()=="1"){
                jcrop_api.destroy();
                $('#cropbox').attr('src', $('#avatar').attr('src').replace("a-", "")+"?time=" + new Date().getTime());
                jcrop_api = $.Jcrop('#cropbox',{
                    onChange: set_avatar_wh,
                    onSelect: set_avatar_wh,
                    aspectRatio: 1,
                    boxWidth: 600
                });
                $('#reloadAvatarCrop').val("0");
            }
        }
    });*/
}


function showMessageError(message){
    $('#message_alert').html(message);
    $('#message_alert').removeClass('success').addClass('error');
    $('#message_alert').show();
}
function showMessageSuccess(message){
    $('#message_alert').html(message);
    $('#message_alert').removeClass('error').addClass('success');
    $('#message_alert').show();
}

$(document).ready(function(){
    
    /*
    jcrop_api = $.Jcrop('#cropbox',{
        onChange: set_avatar_wh,
        onSelect: set_avatar_wh,
        aspectRatio: 1,
        boxWidth: 600
    });
    $('#cropbox_div_container').hide();
*/
    
    
    
    
    
    if($('#avatarUpload').length>0){
        $('#avatarUpload').uploadify({
            'uploader'  : '/js/uploadify/uploadify.swf',
            'script'    : '/js/uploadify/avatar.php',
            'cancelImg' : '/js/uploadify/cancel.png',
            'buttonImg' : '/js/uploadify/BrowseButton.png',
            'rollover'  :true,
            'fileExt'   : '*.jpg;*.gif;*.png;*.jpeg;*.bmp',
            'multi'     : false,
            'auto'      : true,
            'removeCompleted' : true,
            'width'      : 162,
            'height'     : 25,
            'scriptData'  : {
                'upload_type':'avatar',
                'mid':$('#mid').val()
            },
            'onSelect' : function(event,ID,fileObj,data) {
                $(".avatar_loading").show();
            },
            'onAllComplete' : function(event,data) {
                $.ajax({
                    type: "POST",
                    url: "/process.php",
                    data: "action=get_member_avatar&mid="+$('#mid').val(),
                    success: function(avatar){
                        $('#avatar').attr('src', avatar);
                        $(".avatar_loading").hide();
                        $('#reloadAvatarCrop').val("1");
                        
                    }
                });
                
            }
        });
    }
    

    
});
